<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\Db;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        //查询导航菜单
        $nav = Db::name('nav')->select();
        //查询轮播图
        $banner = Db::name('banner')->select();
        //查询新闻公告
        $news = Db::name('news')
            ->order(['createtime' => 'desc', 'id' => 'desc'])
            ->limit(0,3)
            ->select();
        $news2 = Db::name('news')
            ->order(['createtime' => 'desc', 'id' => 'desc'])
            ->limit(3,3)
            ->select();
        //查询党建引领
        $leading = Db::name('leading')->select();
        //查询教研动态
        $teaching = Db::name('teaching')
            ->order(['createtime' => 'desc', 'id' => 'desc'])
            ->limit(0,1)
            ->find();
        $teaching2 = Db::name('teaching')
            ->order(['createtime' => 'desc', 'id' => 'desc'])
            ->limit(1,5)
            ->select();
        //查询社会服务
        $society = Db::name('society')->find();
        //查询主题活动
        $theme = Db::name('theme')
            //->limit(1)
            ->select();
        //查询马院风采
        $mapin = Db::name('mapin')->select();
        //查询友情链接
        $links = Db::name('links')->select();

        $this->view->assign('nav', $nav);
        $this->view->assign('banner', $banner);
        $this->view->assign('news', $news);
        $this->view->assign('news2', $news2);
        $this->view->assign('leading', $leading);
        $this->view->assign('teaching', $teaching);
        $this->view->assign('teaching2', $teaching2);
        $this->view->assign('society', $society);
        $this->view->assign('theme', $theme);
        $this->view->assign('mapin', $mapin);
        $this->view->assign('links', $links);

        return $this->view->fetch('index');
    }

    public function detail()
    {
        $id = input('id/d');
        if(empty(($id))){
            return '参数错误';
        }
        //查询导航菜单
        $nav = Db::name('nav')->select();
        $news = Db::name('news')->find(($id));
        $this->view->assign('nav', $nav);
        $this->assign('article',$news);
        return $this->fetch('detail');
    }


    public function add1()
    {
        return '我不吃牛肉';
    }

}